import requests


def download_image(url):
    headers = {
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.3'}
    print("开始下载： ", url)
    response = requests.get(url,headers)
    print("下载完成")
    # 保存图片到本地
    file_name = url.rsplit('_')[-1]
    with open(file_name, 'wb') as fp:
        fp.write(response.content)


if __name__ == '__main__':
    url_list = [
        'https://car2.autoimg.cn/cardfs/product/g25/M0B/99/EF/1024x0_1_q95_autohomecar__ChwFj19_uIWAQQgZABaZxAqb8BU552.jpg',
        'https://car3.autoimg.cn/cardfs/product/g25/M0A/5E/53/1024x0_1_q95_autohomecar__ChsEmF9zQUuAOt79ACT7Rgx018s791.jpg',
        'https://car2.autoimg.cn/cardfs/product/g26/M01/5B/D4/1024x0_1_q95_autohomecar__ChwFkF9zQc6AesUsACav7Ndb9c4212.jpg'
                ]
    for item in url_list:
        download_image(item)
